package com.byxm.wlgw.service;

import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;

import com.byxm.wlgw.bean.SpxxpxBean;
import com.byxm.wlgw.common.DataBaseAccess;
import com.byxm.wlgw.query.SpxxpxQuery;

public class SpxxpxService {
	SpxxpxQuery query=new SpxxpxQuery();
	public List<SpxxpxBean> findSpxxPx(){//查找出所有的
		
		DataBaseAccess dba=null;
		String sql=query.findSpxxpx("spxx");
		ResultSet rs=null;
		List<SpxxpxBean> list=new ArrayList<SpxxpxBean>();
		try {
			dba=new DataBaseAccess();
			rs=dba.executeQuery(sql);
 			//rs=dba.executeQuery(query.findSpxxpx());
			while(rs.next()){
				SpxxpxBean spxxpxBean=new SpxxpxBean();
				spxxpxBean.setPxid(rs.getInt("pxid"));
				spxxpxBean.setPxsm(rs.getString("pxsm"));
				spxxpxBean.setPxzd(rs.getString("pxzd"));
				spxxpxBean.setSqlgjz(rs.getString("slqgjz"));
				list.add(spxxpxBean);
			}
			rs.close();
		} catch (Exception e) {
			e.printStackTrace();
		}finally{
			try {
				dba.releaseConnect();
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
		return list;
	}
	public SpxxpxBean findSpxxpxBean(int pxid){
		DataBaseAccess dba=null;
		ResultSet rs=null;
		SpxxpxBean spxxpxBean=new SpxxpxBean();
		String sql=query.findSpxxpxOne(pxid);
		try {
			dba=new DataBaseAccess();
			rs=dba.executeQuery(sql);
			while(rs.next()){
				spxxpxBean.setPxid(rs.getInt("pxid"));
				spxxpxBean.setPxsm(rs.getString("pxsm"));
				spxxpxBean.setPxzd(rs.getString("pxzd"));
				spxxpxBean.setSqlgjz(rs.getString("slqgjz"));
			}
		} catch (Exception e) {
			e.printStackTrace();
		}finally{
			try {
				dba.releaseConnect();
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
		return spxxpxBean;
	}
}
